package com.example.sqldemo.controller;


import com.example.sqldemo.Service.SqlService;
import com.example.sqldemo.cursor.TestService;
import com.example.sqldemo.pojo.RuleInfo;
import com.example.sqldemo.spring_transaction.SpringTransactionTest;
import com.example.sqldemo.strategy.Strategy;
import com.example.sqldemo.strategy.StrategyFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sql")
public class SqlController {

    @Autowired
    private SqlService service;

    @Autowired
    private TestService testService;


    @Autowired
    private SpringTransactionTest transactionTest;

    @GetMapping("/v5")
    public void getData5() throws InterruptedException {
        testService.m1();
    }

    @GetMapping("/v6")
    public void insert(){
        service.addData();
    }

    @GetMapping("/v7")
    public void getAudit(){
        service.getAuditData();
    }



    @GetMapping("/v1")
    public List<HashMap<String, Object>> getData1() throws InterruptedException {
       return service.getData3();
    }

    @GetMapping("/v2")
    public void getData2(String sql){
        service.getData2(sql);
    }

    @GetMapping("/v3")
    public void create(String sql){
        service.createTable(sql);
    }

    @PostMapping("/v4")
    public void select(@RequestBody RuleInfo ruleInfo){
        service.get2(ruleInfo);
    }



    @GetMapping("/v8")
    public void insertAuditModel(){
        transactionTest.test2();
    }

    @GetMapping("/v9")
    public void m9(){
        System.out.println("git stash 第一次");
        System.out.println("git stash 第二次");
        System.out.println("git stash 第二次");
        transactionTest.m1();
    }

    @Autowired
    private StrategyFactory strategyFactory;

    @GetMapping("/v10")
    public void m10(){
        Map<String, Strategy> strategyMap = strategyFactory.getStrategyMap();
        Map<String, Strategy> map = strategyFactory.getMap();
    }
}
